#!/bin/bash
#2018年6月4日22:26:43
#auto install LAMP WEB 
#by author www.jfedu.net
########################
#Install Apache WEB 2018
yum install -y wget gcc gcc-c++ tar make  zlib zlib-devel
wget -c https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.32.tar.gz
tar -xzf httpd-2.4.32.tar.gz
cd httpd-2.4.32
./configure --prefix=/usr/local/apache2/ --enable-so --enable-rewrite --enable-ssl --disable-proxy
make
make install
/usr/local/apache2/bin/apachectl start
ps -ef|grep httpd
netstat -tnlp|grep 80
setenforce 0
systemctl stop firewalld.service

#Install MYSQL Database 2018
cd ../
yum  install  cmake  ncurses-devel ncurses -y
wget http://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz 
tar -xzf mysql-5.5.20.tar.gz
cd mysql-5.5.20
cmake  .  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0
make
make install
#Config MYSQL Set System Service
cd /usr/local/mysql55/ 
\cp support-files/my-large.cnf /etc/my.cnf
\cp support-files/mysql.server /etc/init.d/mysqld 
chkconfig --add mysqld 
chkconfig --level 35 mysqld on
mkdir  -p  /data/mysql
useradd  mysql
/usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/
ln  -s  /usr/local/mysql55/bin/* /usr/bin/
service  mysqld  restart

#Install PHP WEB 2018 
cd ../../
wget http://mirrors.sohu.com/php/php-5.6.28.tar.bz2 
tar jxf  php-5.6.28.tar.bz2 
cd php-5.6.28
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc   --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql=/usr/local/mysql55/
make
make install

#Config LAMP WEB and Start Server 2018
echo "AddType application/x-httpd-php .php" >>/usr/local/apache2/conf/httpd.conf
cat>/usr/local/apache2/htdocs/info.php<<EOF
<?php
phpinfo();
?>
EOF
/usr/local/apache2/bin/apachectl start
